﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Wilson/MP/Base.Master" AutoEventWireup="true" CodeBehind="SeriesEdit.aspx.cs" Inherits="WebsiteAdmin.Wilson.ProInfo.SeriesEdit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Head_Title" runat="server">Wilson - 系列编辑 - 产品</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Head_Meta" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Head_Css" runat="server">
    <style type="text/css">
    div.hide{ display:none;}

		#Dialog {
			position: absolute; 
			z-index: 1000; 
			display: none;
			width: 600px;
			background: #FFFFFF;
			border: 3px #999999 solid; 
		}
		#Dialog h6 {
			width: 580px;
			height: 20px;
			line-height: 20px;
			margin: 0;
			padding: 5px 10px; 
			background: #EFEFEF;
			text-align: right; 
			
		}
		#Dialog div.box {
			width: 600px;
			max-height:500px;
			overflow-y:scroll;
		}
		
		#Dialog div#DialogHtml
		{
		    width: 560px;
			padding: 10px; 
			color: #999;
		}
		
		#DialogHtml a {
			float: left;
			height: 20px; 
			line-height: 20px; 
			margin: 5px 15px 5px 0;
			white-space: nowrap;
		}
		
		#DialogHtml h4{ clear:both; background-color:#efefef; font-size:13px; margin-top:5px; display:block; height: 20px; 
			line-height: 20px; padding:5px;}
		
		#DialogHtml b{ float:left; clear:left; height: 20px; 
		    background-color:#efefef;
			line-height: 20px; 
			margin: 3px 15px 3px 0;
			padding:2px;
			white-space: nowrap;}
		
		
        
        #DialogHtml h4 a,#DialogHtml b a{ margin: 0;}	
		
	</style>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Head_Script" runat="server">
    <script type="text/javascript" src="/CKFinder/CKFinder.js"></script>
    <script type="text/javascript" src="/Script/Mootools.Smoothbox.js"></script>
<script type="text/javascript" language="javascript">
    var MenuViewID = 2;
    
    Array.implement({
        getFirstRadio: function() {
            if (this.length == 0) {
                return null;
            }
            return this[0];
        }
    });
    window.addEvent('domready', function() {
        
        if (typeof(CKFinder) == 'undefined') {
			alert('加载CKFinder失败');
		} 
        
        $('submitbtn').addEvent('click', function() {
            Submit();
        });
        
        $('ShowLink').addEvent('click', function() {
				BrowseServer('Images:/Series/', 'txbImgURL','ShowView');

		});
		$('selCatList').set('value',<%=catID %>); 
    });
    
    function SetFileField(fileUrl, data) {
            $(data["selectActionData"]).value = fileUrl;
			$(this).setProperty('src', fileUrl);			
		}
	function BrowseServer(startupPath, functionData, element) {
		var finder = new CKFinder();
		finder.startupPath = startupPath;
		finder.selectActionData = functionData;
		finder.selectActionFunction = SetFileField.bind(element);
		finder.popup();
		}

    function Submit() {

        var txbCatID = $('selCatList').get('value').trim().toInt();
        if (isNaN(txbCatID)) {
            alert('请选择分类');
            return false;
        }
        var txbSerTitle = $('txbSerTitle').get('value').trim();
        if (txbSerTitle.length == 0) {
            alert('标题错误');
            return false;
        }
        var txbDescription = $('txbDescription').get('value').trim();

        var txbImgURL = $('txbImgURL').get('value').trim();
        var txbSortOrder = $('txbSortOrder').get('value').trim().toInt();
        if (isNaN(txbSortOrder)) {
            alert('必须是整数');
            return false;
        }
        Update(
        txbCatID,
        txbSerTitle,
        txbDescription,
        txbImgURL,
        txbSortOrder);
    }

    function Update(txbCatID,
        txbSerTitle,
        txbDescription,
        txbImgURL,
        txbSortOrder) {

        new Request.JSON({
            method: 'post',
            url: 'Handler/SeriesUpdate.ashx',
            data: {
                PKID : <%=pkid %>,
                CatID: txbCatID,
                SerTitle: txbSerTitle,
                Description: txbDescription,
                ImgURL: txbImgURL,
                SortBy: txbSortOrder
            },
            noCache: true,
            onSuccess: function(data, text) {
                if (data.Done == 'Success') {

                    if (confirm('修改成功，返回列表？')) {
                        document.location.href = '/Wilson/ProInfo/SeriesList.aspx';
                    };
                    LightBox.remove();
                }
                else {
                    alert('修改失败');
                    LightBox.remove();
                }
            },
            onFailure: function(xhr) {
                alert(xhr.statusText);
                LightBox.remove();
            }
        }).send();
    }
		
</script>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Body_Top" runat="server">
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="Body_Content" runat="server">
    <div class="infobox">
        <h3>
        <span>系列编辑</span>
			<a href="/Wilson/ProInfo/SeriesList.aspx" class="back action">返回系列列表</a>
        </h3>
        <div class="mt10">
        <form id="myForm" action="">
		    <table border="0" cellpadding="0" cellspacing="0" class="table_form">
		        <tr>
            		<td align="right" width="100"><span class="Need">所属分类：</span></td>
            		<td>
            			<select id="selCatList">
            			    <asp:Repeater ID="repCatList" runat="server" EnableViewState="false">
            			        <ItemTemplate>
            			            <option value="<%#Eval("PKID") %>"><%#Eval("CatName") %></option>
            			        </ItemTemplate>
            			    </asp:Repeater>
            			</select>
            		</td>
				</tr>
		        <tr>
            		<td align="right" width="100"><span class="Need">系列名称：</span></td>
            		<td>
            			<input name="txbSerTitle" type="text" id="txbSerTitle" maxlength="20" size="20" value="<%=serName %>" />
            			<i>限10个汉字</i>
            		</td>
				</tr>
				<tr>
            		<td align="right" width="100"><span class="Need">简介：</span></td>
            		<td>
            			<textarea name="txbDescription" rows="3" cols="20" id="txbDescription"><%=description%></textarea>
            		</td>
				</tr>
				<tr>
                    <td align="right" width="100">
                        图片：</td>
                    <td>
                           <input type="text" id="txbImgURL" name="txbImgURL" style="width:450px; color:#666; background-color:#efefef; border:1px #ccc solid;" readonly="readonly"  value="<%=imgURL %>" /> <font color="red">*&nbsp;</font>
                           <a id="ShowLink" style="cursor:pointer;cursor:hand;border:solid 1px;padding:0 10px 0 10px;">浏览</a>
                    </td>
                </tr>
                <tr>
                    <td align="right" width="100">&nbsp;</td>
                    <td>
                        <div style=" width:300px; height:224px; overflow:hidden; border:1px #999 solid; background-color:#f8f8f8; clear:both;">
                           <img id="ShowView" alt="" src="<%=imgURL%>" />
                        </div>
                        <i>图片尺寸 300 x 224。</i><br />
                        <i>如果图片不能完全填充，请重新选择图片。</i>
                    </td>
                </tr>
				<tr>
            		<td align="right" width="100"><span class="Need">显示排序：</span></td>
            		<td>
            			<input name="txbSortOrder" type="text" id="txbSortOrder" maxlength="2" size="5" value="<%=sortBy %>" />
            			<i>请输入数字</i>
            		</td>
				</tr>
		    </table>
		    <table border="0" cellpadding="0" cellspacing="0" class="table_form">
				<tr>
					<td width="100" height="40">&nbsp;</td>
					<td>
						<input id="submitbtn" type="button" value="提交" class="btn" />
						<input type="reset" value="重置" class="btn" />
					</td>
				</tr>
			</table>
		</form>
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="Body_Foot" runat="server">
</asp:Content>
